<?php
/**
 * 
 * 팀원 정보 model
 * @author gudals
 *
 */

class modelContTeamMember extends modelContBase
{
    /**
     * 
     * 팀원 정보 리스트
     * @param int $iTeamNo 팀 번호
     */
    public function getList($iTeamNo)
    {
        $subQuery = "";
        if (empty($iTeamNo) === false) {
            $subQuery = "where team_no = '".$iTeamNo."'";
        }
        
        $sQuery = "
            select
                *
            from
                team_member
            ".$subQuery."
            order by
            team_no
        ";
        
        return $this->executeQuery($sQuery, 'rows');
    }
    
    /**
     * 
     * 아이디 중복 체크 조회
     * @param string $sMemberId 아이디
     * @return boolean|Ambigous <NULL, multitype:void , void, unknown>
     */
    public function getMemberInfo($sMemberId)
    {
        if (empty($sMemberId)) return false;
        
        $sQuery = "
            select
                member_no
            from
                team_member
            where
                member_id = '".$sMemberId."'
        ";
        
        return $this->executeQuery($sQuery, 'row');
    }
    
    /**
     * 
     * 팀원 등록
     * @param array $aReq 등록정보
     * @return boolean
     */
    public function insert($aReq)
    {
        if (empty($aReq)) return false;
        
        $sQuery = "
            insert into team_member (
                team_no,
                member_id,
                member_pass,
                member_name,
                member_email,
                member_level
            ) values (
                '".$aReq['m_team_no']."',
                '".$aReq['member_id']."',
                '".$aReq['member_pass']."',
                '".$aReq['member_name']."',
                '".$aReq['member_email']."',
                '".$aReq['member_level']."'
            )
        ";
        
        $this->executeQuery($sQuery, 'exec');
        return $this->lastInsertID();
    }
}